package com.ht.impl.dialogs;

import com.ht.aems.swing.component.AColorChooser2;
import com.ht.impl.ResourceTypeCons;
import com.mxgraph.util.mxUtils;

import javax.swing.*;
import java.awt.*;
import java.util.Map;
import java.util.HashMap;

/**
 * @author wang
 *         Date: 2010-7-7
 */
public class ColorPane extends JPanel implements ResourceTypeCons {
    JTextField textField;
    AColorChooser2 aColorChooser2;

    public ColorPane(String name, String content) {
        setName(name);
        textField = new JTextField(content.equals("") ? "" : content.split(MARK_SPLIT)[0]);
        aColorChooser2 = new AColorChooser2(content.equals("") ? Color.BLUE : mxUtils.parseColor(content.split(MARK_SPLIT)[1]));
        setLayout(new GridLayout(1, 2, 20, 2));
        add(textField);
        add(aColorChooser2);
    }

    public Map<Object, Object> getStyle() {
        Map<Object, Object> style = new HashMap<Object, Object>(1);
        style.put(textField.getText(), aColorChooser2.getColorChoosed());
        return style;
    }
}
